<?php

namespace yiike\user\widgets;

use Yii;
use yii\helpers\Html;

/**
 * Description of UserPicker
 *
 * @author Sylar
 */
class UserPicker extends \yii\widgets\InputWidget {

    public $containerOptions;

    public function run() {

        $searchModel  = Yii::createObject(\dektrium\user\models\UserSearch::className());
        $dataProvider = $searchModel->search(Yii::$app->request->get());
        //$dataProvider->pagination->pageSize = 3;

        if ($this->hasModel()) {
            $attribute   = $this->attribute;
            $this->value = $this->model->$attribute;
        }

        $user = \yiike\user\models\User::findOne($this->value);

        $modal = $this->render('user-picker', [
            'dataProvider' => $dataProvider,
            'searchModel'  => $searchModel,
            'widget'       => $this,
            'user'         => $user
        ]);

        return Html::tag('div', $modal);
    }

}
